package net.liuwenwen;

import java.util.Scanner;

public class Account
{
    private long accountNumber;
    private double balance;

    public Account(long accountNumber,double balance)
    {
        this.accountNumber = accountNumber;
        this.balance = balance;
    }

    public long getAccountNumber() {
        return accountNumber;
    }

    public double getBalance() {
        return balance;
    }

    public void depositMoney() {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入存款数目：");
        double newDeposit = in.nextDouble();
        this.balance = this.balance + newDeposit;
        System.out.println("您的存款金额为" + newDeposit + "元");
        System.out.println("账户余额为" + this.balance + "元");
    }

    public void withdrawMoney() {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入取款数目：");
        double newWithdraw = in.nextDouble();
        if(newWithdraw > this.balance) {
            System.out.println("对不起，余额不足");
        }
        else {
            this.balance = this.balance - newWithdraw;
            System.out.println("您的取款金额为" + newWithdraw + "元");
            System.out.println("账户余额为" + this.balance + "元");
        }
    }
}